package com.zenni.test;

import com.zenni.core.MainPageVariables;
import com.zenni.core.OrderVariables;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.net.URL;

/**
 * Created by douglasj on 2/15/16.
 */
public class test  {
    RemoteWebDriver driver = null;
    @Test
    public void testrun() throws Exception{

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Safari");
        capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone");
        capabilities.setCapability(MobileCapabilityType.UDID, "e1745ee18a9f87e8d5bd310324686f80a4f28afa");
        driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
        //driver.manage().deleteAllCookies();
        driver.get("http://www.zennioptical.com");
        driver.findElement(By.xpath("//section[@class = 'ui-best-sellers margin-top50 margin-bottom50']/div[@class = 'best-sellers slick-initialized slick-slider']/div[@class = 'slick-list draggable']/div[@class ='slick-track']/div[1]/div[@ class = 'row ui-hover']/div[2]/button")).click();
        Thread thread = new Thread();
        thread.sleep(3000);
        Select prescriptiontype_menu = new Select(driver.findElement(By.id(OrderVariables.prescriptiontype_menu_id)));
        prescriptiontype_menu.selectByValue("SingleVision");
        driver.findElement(By.id(OrderVariables.prescription_next_button_id)).click();
        /*Thread thread = new Thread();
        thread.sleep(15000);
        driver.findElement(By.xpath("//header[@id = 'new-top-navigation']/nav/div/ul/li/button")).click();
        JavascriptExecutor js = (JavascriptExecutor)driver;
        //js.executeScript("document.getElementsByClassName(\"nav-women\")[0].click()"); 2.17
        js.executeScript("document.getElementsByClassName(\"nav-women\")[1].click()");
        //driver.findElement(By.xpath("/html/body/div[1]/header/nav/div[1]/ul/li[3]/ul/li[1]")).click(); 2.17
        //Thread thread = new Thread();
        thread.sleep(3000);
        //driver.findElement(By.xpath(MainPageVariables.women_new_arrival_xpath_main_page)).click(); 2.17
        driver.findElement(By.xpath("//*[@id=\"side-nav\"]/ul/li[1]/ul/li[2]/a")).click();
        thread.sleep(3000);
        //JavascriptExecutor js1 = (JavascriptExecutor)driver; 2.17
        //js1.executeScript("document.getElementsByClassName(\"thumbOver\")[0].style.display=\"block\"");2.17
        //driver.findElement(By.xpath("//ul[@class = 'categoryList']/li[1]")).click();
        /*Select cat = new Select(driver.findElement(By.id("sortBySelecter")));
        cat.selectByIndex(2);
        //thread.sleep(3000);2.17
        //driver.findElement(By.xpath("/html/body/div[1]/div[1]/div/div[2]/div[1]/ul/li[4]/div/div/p[2]/a[3]")).click();
        //js.executeScript("document.getElementsByClassName(\"btnBox\")[0].childNodes[5].click()"); 2.17
        driver.findElement(By.xpath("//ul[@class = 'categoryList']/li/div/div/p[@class = 'btnBox']/a[3]")).click();
        thread.sleep(3000);
        Select prescriptiontype = new Select(driver.findElement(By.id("prescriptionType")));
        prescriptiontype.selectByValue("Progressive");
        Select odSPH = new Select(driver.findElement(By.id("odSph")));
        odSPH.selectByValue("-4.50");
        Select osSPH = new Select(driver.findElement(By.id("osSph")));
        osSPH.selectByValue("-4.50");
        Select odCYL = new Select(driver.findElement(By.id("odCyl")));
        odCYL.selectByValue("-4.50");
        Select osCYL = new Select(driver.findElement(By.id("osCyl")));
        osCYL.selectByValue("-4.50");
        Select odAXIS = new Select(driver.findElement(By.id("odAxis")));
        odAXIS.selectByValue("2");
        Select osAXIS = new Select(driver.findElement(By.id("osAxis")));
        osAXIS.selectByValue("2");
        Select nvADD = new Select(driver.findElement(By.id("nvAdd")));
        nvADD.selectByValue("1.00");
        //driver.findElement(By.xpath("//span[@id = 'notEnablePrism']/input[1]")).click();
        //driver.findElement(By.xpath("//span[@id = 'spanSignlePD']/input[1]")).click();
        Select pdvalue = new Select(driver.findElement(By.id("pdSingle")));
        pdvalue.selectByValue("70");
        thread.sleep(3000);
        driver.findElement(By.id("prescriptionNext")).click();
        thread.sleep(3000);
        //driver.findElement(By.xpath("//a[contains(text(),'OK')]")).click();
        driver.findElement(By.id("lensSubmitButton")).click();
        thread.sleep(3000);
        driver.findElement(By.id("btnAddToCart")).click();
        thread.sleep(3000);*/
    }
}
